﻿
<ValueConversion(GetType(FuncClasses.Dokumentart), GetType(String))> _
Public Class OrderTypeConverter
    Implements IValueConverter

#Region "IValueConverter Members"
    Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
        Dim item As FuncClasses.Dokumentart
        Try
            item = CInt(value)
        Catch ex As Exception
            Return ConvertBack(value, Nothing, Nothing, Nothing)
        End Try

        Select Case item
            Case FuncClasses.Dokumentart.Angebot
                Return "Angebot"
            Case FuncClasses.Dokumentart.Gutschrift
                Return "Gutschrift"
            Case FuncClasses.Dokumentart.Lieferschein
                Return "Lieferschein"
            Case FuncClasses.Dokumentart.Rechnung
                Return "Rechnung"
        End Select
        Return "Unbekannter Typ - " + item.ToString
    End Function

    Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
        Dim item As String = value
        Select Case item
            Case "Angebot"
                Return FuncClasses.Dokumentart.Angebot
            Case "Gutschrift"
                Return FuncClasses.Dokumentart.Gutschrift
            Case "Lieferschein"
                Return FuncClasses.Dokumentart.Lieferschein
            Case "Rechnung"
                Return FuncClasses.Dokumentart.Rechnung
        End Select
        Return "Unbekannter Typ - " + item.ToString
    End Function
#End Region
End Class